home *** CD-ROM | disk | FTP | other *** search
- Path: news.acadia.net!usenet
- From: steven2@salesbook.com (Steve Nutt)
- Newsgroups: comp.lang.c++
- Subject: Re: What does TSomeObject *& SomeFunction(); mean
- Date: Sun, 03 Mar 1996 06:59:33 GMT
- Organization: DET
- Message-ID: <4hb7a3$9gm@post.acadia.net>
- References: <4h847u$5ha@ee.rutgers.edu>
- Reply-To: steven2@salesbook.com
- NNTP-Posting-Host: blf7.acadia.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- imranh@ee.rutgers.edu (Imran Hussain) wrote:
-
- >Hi,
- >What is the difference between:
-
- >TSomeObject*& SomeFunction(); and
- >TSomeObject* SomeFunction();
-
- >I know what the later means, but don't know the first one. Can
- >someone please help me out...
-
-
- >Thanks,
- >Imran
-
- It returns a reference to a pointer to a TSomeObject.
-
- As an example.
-
-
- class A
- {
- public:
- A (void) {};
- };
-
- class B
- {
- public:
- B (void) { a = 0; }
- A*& GetAndSetA (void) { return a; }
-
- private:
- A* a;
- };
-
- main ()
- {
- A a;
- B b;
- b.GetAndSetA() = &a;
- A* aPointer = b.GetAndSetA();
-
- if (&a != aPointer)
- throw "Either I've no idea what I'm talking about, or you've got a
- crummy compiler";
-
- return 0;
- }
-
-